package org.example.petsystem.service.impl;

import org.example.petsystem.entity.ResultBody;
import org.example.petsystem.mapper.BookingMapper;
import org.example.petsystem.service.BookingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class BookingServiceimpl implements BookingService {
    @Autowired
    private BookingMapper bookingMapper;
    @Override
    public ResultBody addBooking(Map<String,Object> map) {
       if(bookingMapper.addBooking(map)>0)
       {
           return new ResultBody(200,"预约成功",true);
       }
       else
           return new ResultBody(400,"预约失败",false);
    }
    @Override
    public ResultBody displayBooking() {
        if(!bookingMapper.displayBooking().isEmpty()){
            return new ResultBody(200,"展示预约成功",bookingMapper.displayBooking(),bookingMapper.displayBooking().size());
        }
        else if (bookingMapper.displayBooking().isEmpty())
        {
            return new ResultBody(200,"暂时未有预约",bookingMapper.displayBooking());
        }
           return new ResultBody(400,"展示预约失败",false);
    }
    @Override
    public ResultBody displayBookingR() {
        if(!bookingMapper.displayBookingR().isEmpty()) {
            return new ResultBody(200, "展示预约成功", bookingMapper.displayBookingR(), bookingMapper.displayBookingR().size());
        }
        if (bookingMapper.displayBookingR().isEmpty())
        {
            return new ResultBody(200,"暂时未有预约",bookingMapper.displayBookingR());
        }
        return new ResultBody(400,"展示预约失败",false);
    }
    @Override
    public ResultBody displayUserBooking(Map<String,Object> map) {
        if(!bookingMapper.displayUserBooking(map).isEmpty()) {
            return new ResultBody(200, "展示预约成功", bookingMapper.displayUserBooking(map), bookingMapper.displayUserBooking(map).size());
        }
        if (bookingMapper.displayUserBooking(map).isEmpty())
        {
            return new ResultBody(200,"暂时未有预约",bookingMapper.displayUserBooking(map));
        }
        return new ResultBody(400,"展示预约失败",false);
    }
    @Override
    public ResultBody checkBooking(Map<String,Object> map) {
        if(bookingMapper.checkBooking(map)>0) {
            return new ResultBody(200, "审核成功", true);
        }
        return new ResultBody(400,"审核失败",false);
    }
    @Override
    public ResultBody addservice(Map<String,Object> map) {
        if(bookingMapper.addservice(map)>0) {
            return new ResultBody(200, "增加服务成功", true);
        }
        return new ResultBody(400,"增加服务失败",false);
    }

    @Override
    public ResultBody updateservice(Map<String,Object> map) {
        if(bookingMapper.updateservice(map)>0) {
            return new ResultBody(200, "修改服务成功", true);
        }
        return new ResultBody(400,"修改服务失败",false);
    }
    @Override
    public ResultBody delservice(Map<String,Object> map) {
        if(bookingMapper.delservice(map)>0) {
            return new ResultBody(200, "删除服务成功", true);
        }
        return new ResultBody(400,"删除服务失败",false);
    }
    @Override
    public ResultBody displayservice() {
        if(!bookingMapper.displayservice().isEmpty()){
            return new ResultBody(200,"展示服务成功",bookingMapper.displayservice(),bookingMapper.displayservice().size());
        }
        else if (bookingMapper.displayservice().isEmpty())
        {
            return new ResultBody(200,"暂时未有服务",bookingMapper.displayservice());
        }
        return new ResultBody(400,"展示预约失败",false);
    }
}
